home *** CD-ROM | disk | FTP | other *** search
/ F1 Licenseware / F1 Licenseware - Volume 1.iso / disks / 055a.dms / 055a.adf / READERS_SOURCE.LHA / READERS_SOURCE / ED_CLAY / medsample2.amos / medsample2.amosSourceCode < prev    next >
AMOS Source Code  |  1992-02-26  |  3KB  |  96 lines

  1. '
  2. ' Med with samples   
  3. ' By Edmund Clay 
  4. ' June 94  
  5. '
  6. ' This cures the problem that all samples are looped after a med module
  7. ' has been loaded. 
  8. ' This is an update to the program on AZ#2, which had a few bugs (not  
  9. ' surprising given that what I am trying to do is Not Recommended, 
  10. ' illegal and entirely immoral) If all goes well, this is the procedure I  
  11. ' will use in GRAC, the graphic adventure creator which I am writing. It 
  12. ' will support both Med and ST modules, with sound effects. Incidently,
  13. ' The ST play command from the CRAFT extension is the most reliable music  
  14. ' system for Amospro, if you can live without med. It can suspend music
  15. ' on individual channels while a sample is playing and you can also set
  16. ' the starting pattern.
  17. '
  18. '----------------------------------------------------------------------
  19. '
  20. 'Needs a small, blank memory bank. 
  21. '
  22. Reserve As Work 4,1024
  23. Fill Start(4) To Start(4)+Length(4),0
  24. '
  25. ' Load a med module... 
  26. '
  27. Med Load Fsel$(""),6
  28. '
  29. ' Play until mouse 
  30. '
  31. Print "Playing module, click mouse to stop."
  32. Med Play 6
  33. While Mouse Key=0 : Wend 
  34. While Mouse Key<>0 : Wend 
  35. '
  36. ' Stop the module  
  37. '
  38. Med Stop 
  39. Print "Click mouse to play sample."
  40. Do 
  41.    While Mouse Key=0 : Wend 
  42.    While Mouse Key<>0 : Wend 
  43.    '
  44.    ' Play sample  
  45.    '  
  46.    SAM["%1000",1,10000,0]
  47. Loop 
  48. '  
  49. ' An interesting point is that this bug actually works to your advantage,
  50. ' because you can now choose whether to have individual samples looped or not, 
  51. ' which AMOS doesn't normally allow. 
  52. ' If you try to play samples at the same time as Med modules, you have no  
  53. ' control over the frequency if med is using the same channel. 
  54. ' Unfortunately this will have to wait for a proper fix.   
  55. '
  56. Procedure SAM[VO1CE$,S4MPLE,FREQUENCY,L00P]
  57.    '
  58.    ' Parameters as the normal sam play command.   
  59.    ' The voice bitmap has to be a string because I can't get btst to work.  
  60.    ' L00P=0 - not looped
  61.    ' L00P=-1 - looped     
  62.    '
  63.    '--------------------------------------------------------------------- 
  64.    '
  65.    ' Assumes that samples are in bank 5.
  66.    '
  67.    STRT=Start(5)+Leek(Start(5)+2+4*(S4MPLE-1))+14
  68.    LGTH=Leek(Start(5)+Leek(Start(5)+2+4*(S4MPLE-1))+10)
  69.    '
  70.    ' This makes sure that the first word of the sample is zero. The sample
  71.    ' is stopped from playing by looping just the first word. It will squeal 
  72.    ' horribly if it is not zero.
  73.    '  
  74.    Doke STRT,0
  75.    '
  76.    ' This bit sets a silent sample going. 
  77.    '
  78.    Sam Raw Val(VO1CE$),Start(4),257,FREQUENCY
  79.    '
  80.    'I then hijack the audio system for my own purposes
  81.    '
  82.    If Mid$(VO1CE$,5,1)="1" : Loke $DFF0A0,STRT : Doke $DFF0A4,LGTH/2 : End If 
  83.    If Mid$(VO1CE$,4,1)="1" : Loke $DFF0B0,STRT : Doke $DFF0B4,LGTH/2 : End If 
  84.    If Mid$(VO1CE$,3,1)="1" : Loke $DFF0C0,STRT : Doke $DFF0C4,LGTH/2 : End If 
  85.    If Mid$(VO1CE$,2,1)="1" : Loke $DFF0D0,STRT : Doke $DFF0D4,LGTH/2 : End If 
  86.    '
  87.    'Stop the sample from looping. 
  88.    '
  89.    If Not L00P
  90.       Wait(100*257)/FREQUENCY
  91.       If Mid$(VO1CE$,5,1)="1" : Doke $DFF0A4,1 : End If 
  92.       If Mid$(VO1CE$,4,1)="1" : Doke $DFF0B4,1 : End If 
  93.       If Mid$(VO1CE$,3,1)="1" : Doke $DFF0C4,1 : End If 
  94.       If Mid$(VO1CE$,2,1)="1" : Doke $DFF0D4,1 : End If 
  95.    End If 
  96. End Proc